package com.qyhl.webtv.module_user.serviceimp;

import android.content.Context;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.qyhl.webtv.basiclib.base.BaseFragment;
import com.qyhl.webtv.commonlib.constant.AppConfigConstant;
import com.qyhl.webtv.commonlib.constant.ServicePathConstant;
import com.qyhl.webtv.commonlib.service.UserService;
import com.qyhl.webtv.commonlib.utils.config.AppConfigUtil;
import com.qyhl.webtv.commonlib.utils.inter.HomeActivityInterface;
import com.qyhl.webtv.module_user.home.UserCenterFragment;
import com.qyhl.webtv.module_user.util.LoginUtils;

/**
 * 用户对外暴露的接口实现
 * @author  helin
 * @date  2019年2月27日20:28:53
 */
@Route(path = ServicePathConstant.USER_SERICE)
public class UserServiceImpl implements UserService {

    private Context mContext;

    /**
     * 获取用户电话
     * @return
     */
    @Override
    public String getUserPhone() {
        return (String) AppConfigUtil.getInstance().getConValue(AppConfigConstant.USER_NAME);
    }

    /**
     * 用户是否登陆
     * @return
     */
    @Override
    public void checkUserLogin(LoginCallBack callBack) {

        LoginUtils.checkLogin( new LoginUtils.LoginCallBack() {
            @Override
            public void login(boolean isLogin) {
                callBack.login(isLogin);
            }

            @Override
            public void error(String s) {
                callBack.error(s);
            }
        });

    }

    @Override
    public BaseFragment getUserCenterFragment(HomeActivityInterface homeActivityInterface) {
        return UserCenterFragment.newInstance(homeActivityInterface);
    }


    /**
     * 初始化
     * @param context
     */
    @Override
    public void init(Context context) {
        mContext = context;
    }
}
